package com.arpa.oms.domain.entity;

import com.arpa.wms.domain.entity.BasicEntity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.Digits;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;

/**
 * <p>
 * OMS销售明细
 * </p>
 *
 * @author LEO
 * @since 2020-10-22
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("oms_sale_item")
@ApiModel(value = "OmsSaleItem对象", description = "OMS销售明细")
public class SaleItem extends BasicEntity {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "数据标识")
    @TableField("code")
    private String code;

    @ApiModelProperty(value = "销售单号")
    @TableField("sale_code")
    private String saleCode;

    @ApiModelProperty(value = "商品标识",required = true)
    @NotEmpty(message = "商品标识不能为空")
    @TableField("goods_code")
    private String goodsCode;

    @ApiModelProperty(value = "商品编码",required = true)
    @NotEmpty(message = "商品编码不能为空")
    @TableField("good_code")
    private String goodCode;

    @ApiModelProperty(value = "商品名称",required = true)
    @NotEmpty(message = "商品名称不能为空")
    @TableField("goods_name")
    private String goodsName;

    @ApiModelProperty(value = "商品条码")
    @TableField("goods_bar_code")
    private String goodsBarCode;

    @ApiModelProperty(value = "商品规格")
    @TableField("spec")
    private String spec;

    @ApiModelProperty(value = "保质期（天）",required = true)
    @TableField("expiration_quantity")
    @NotNull(message = "保质期（天）不能为空")
    private BigDecimal expirationQuantity;

    @ApiModelProperty(value = "基本单位",required = true)
    @NotEmpty(message = "基本单位标识不能为空")
    @TableField("basic_unit")
    private String basicUnit;

    @ApiModelProperty(value = "基本单位名称")
    @TableField("basic_unit_name")
    private String basicUnitName;

    @ApiModelProperty(value = "当前商品单位转基本单位件装量",required = true)
    @NotNull(message = "当前商品单位转基本单位件装量不能为空")
    @TableField("unit_convert_quantity")
    private BigDecimal unitConvertQuantity;

    @ApiModelProperty(value = "销售单位",required = true)
    @NotEmpty(message = "销售单位标识不能为空")
    @TableField("sale_unit")
    private String saleUnit;

    @ApiModelProperty(value = "销售单位名称",required = true)
    @NotEmpty(message = "销售单位名称不能为空")
    @TableField("sale_unit_name")
    private String saleUnitName;

    @ApiModelProperty(value = "订单数量（销售单位）",required = true)
    @NotNull(message = "销售数量不能为空")
    @TableField("plan_quantity")
    @Digits(integer = 14,fraction = 6, message = "销售数量超过了允许范围（只允许14位整数和6位小数范围内）", groups = {Sale.Save.class, Sale.Update.class})
    private BigDecimal planQuantity;

    @ApiModelProperty(value = "实际销售数量（销售单位），即出库数量（销售单位）")
    @TableField("actual_quantity")
    private BigDecimal actualQuantity;

    @ApiModelProperty(value = "订单数量（基本单位）")
    @TableField("plan_basic_quantity")
    private BigDecimal planBasicQuantity;

    @ApiModelProperty(value = "实际销售数量（基本单位），即出库数量（基本单位）")
    @TableField("actual_basic_quantity")
    private BigDecimal actualBasicQuantity;

    @ApiModelProperty(value = "退货数量（销售单位）")
    @TableField("refund_quantity")
    private BigDecimal refundQuantity;

    @ApiModelProperty(value = "退货数量（基本单位）")
    @TableField("refund_basic_quantity")
    private BigDecimal refundBasicQuantity;

    @ApiModelProperty(value = "税率",required = true)
    @NotNull(message = "税率不能为空")
    @TableField("tax_rate")
    private BigDecimal taxRate;


    @ApiModelProperty(value = "单价",required = true)
    @TableField("unit_price")
    @NotNull(message = "单价不能为空")
    @Digits(integer = 14,fraction = 6, message = "单价超过了允许范围（只允许14位整数和6位小数范围内）", groups = {Sale.Save.class, Sale.Update.class})
    private BigDecimal unitPrice;


    @ApiModelProperty(value = "含税单价")
    @TableField("tax_unit_price")
    private BigDecimal taxUnitPrice;


    @ApiModelProperty(value = "金额")
    @TableField("amount_money")
    private BigDecimal amountMoney;

    @ApiModelProperty(value = "税额")
    @TableField("tax_money")
    private BigDecimal taxMoney;

    @ApiModelProperty(value = "价税合计")
    @TableField("total_money")
    private BigDecimal totalMoney;

    @ApiModelProperty(value = "备注")
    @TableField("remarks")
    @Length(max = 255, message = "明细备注最多输入255个字符")
    private String remarks;

    @ApiModelProperty(value = "折扣金额")
    @TableField("discount_amount")
    private BigDecimal discountAmount;

    @ApiModelProperty(value = "是否批量新增 0-否 1-是")
    @TableField("is_batchAdd")
    private Integer batchAdd;

    @ApiModelProperty(value = "是否组合商品：0-不是，1-是")
    private Integer recordType;

    @ApiModelProperty(value = "外部商品编码")
    @TableField("outer_goods_code")
    private String outerGoodsCode;

    @ApiModelProperty(value = "外部商品名称")
    @TableField("outer_goods_name")
    private String outerGoodsName;

    @ApiModelProperty(value = "赠品数量")
    @TableField("gift_quantity")
    private BigDecimal giftQuantity;
}
